﻿using System.Collections.Generic;
using System.Linq;
using DxMvcApplication.AccountingServiceReference;
using DxMvcApplication.Areas.Administrator.Models.Report;

namespace DxMvcApplication.Areas.Administrator.Models.Dictionary
{
    /// <summary>
    /// Mapper class
    /// </summary>
    public static class Mapper
    {
        #region FromModels

        /// <summary>
        /// to
        /// To the data transfer objects.
        /// </summary>
        /// <param name="c">The c.</param>
        /// <returns></returns>
        public static IList<DepartmentDto> FromModels(this IEnumerable<DepartmentModel> c)
        {
            return c == null ? null : c.Select(source => FromModel((source))).ToList();
        }

        /// <summary>
        /// To the data transfer objects.
        /// </summary>
        /// <param name="c">The c.</param>
        /// <returns></returns>
        public static IList<UnitDto> FromModels(this IEnumerable<UnitModel> c)
        {
            return c == null ? null : c.Select(source => FromModel((source))).ToList();
        }

        /// <summary>
        /// To the data transfer objects.
        /// </summary>
        /// <param name="c">The c.</param>
        /// <returns></returns>
        public static IList<CustomerDto> FromModels(this IEnumerable<CustomerModel> c)
        {
            return c == null ? null : c.Select(source => FromModel((source))).ToList();
        }

        /// <summary>
        /// Froms the models.
        /// </summary>
        /// <param name="c">The c.</param>
        /// <returns></returns>
        public static IList<CustomerModel> FromModels(this IEnumerable<CustomerDto> c)
        {
            return c == null ? null : c.Select(source => FromModel((source))).ToList();
        }

        /// <summary>
        /// To the data transfer objects.
        /// </summary>
        /// <param name="c">The c.</param>
        /// <returns></returns>
        public static IList<VendorDto> FromModels(this IEnumerable<VendorModel> c)
        {
            return c == null ? null : c.Select(source => FromModel((source))).ToList();
        }

        /// <summary>
        /// To the data transfer objects.
        /// </summary>
        /// <param name="c">The c.</param>
        /// <returns></returns>
        public static IList<VoucherTypeDto> FromModels(this IEnumerable<VoucherTypeModel> c)
        {
            return c == null ? null : c.Select(source => FromModel((source))).ToList();
        }

        /// <summary>
        /// To the data transfer objects.
        /// </summary>
        /// <param name="c">The c.</param>
        /// <returns></returns>
        public static IList<RefTypeDto> FromModels(this IEnumerable<RefTypeModel> c)
        {
            return c == null ? null : c.Select(source => FromModel((source))).ToList();
        }

        /// <summary>
        /// To the data transfer objects.
        /// </summary>
        /// <param name="c">The c.</param>
        /// <returns></returns>
        public static IList<AutoBusinessDto> FromModels(this IEnumerable<AutoBusinessModel> c)
        {
            return c == null ? null : c.Select(source => FromModel((source))).ToList();
        }

        /// <summary>
        /// To the data transfer objects.
        /// </summary>
        /// <param name="c">The c.</param>
        /// <returns></returns>
        public static DbOptionDto[] FromModels(this IEnumerable<DbOptionModel> c)
        {
            return c == null ? null : c.Select(source => FromModel((source))).ToArray();
        }

        /// <summary>
        /// to
        /// To the data transfer objects.
        /// </summary>
        /// <param name="c">The c.</param>
        /// <returns></returns>
        public static IList<StockDto> FromModels(this IEnumerable<StockModel> c)
        {
            return c == null ? null : c.Select(source => FromModel((source))).ToList();
        }

        /// <summary>
        /// to
        /// To the data transfer objects.
        /// </summary>
        /// <param name="c">The c.</param>
        /// <returns></returns>
        public static IList<InventoryItemDto> FromModels(this IEnumerable<InventoryItemModel> c)
        {
            return c == null ? null : c.Select(source => FromModel((source))).ToList();
        }

        /// <summary>
        /// to
        /// To the data transfer objects.
        /// </summary>
        /// <param name="c">The c.</param>
        /// <returns></returns>
        public static IList<AccountDto> FromModels(this IEnumerable<AccountModel> c)
        {
            return c == null ? null : c.Select(source => FromModel((source))).ToList();
        }

        /// <summary>
        /// to
        /// To the data transfer objects.
        /// </summary>
        /// <param name="c">The c.</param>
        /// <returns></returns>
        public static IList<ReportListDto> FromModels(this IEnumerable<ReportListModel> c)
        {
            return c == null ? null : c.Select(source => FromModel((source))).ToList();
        }

        /// <summary>
        /// to
        /// To the data transfer objects.
        /// </summary>
        /// <param name="c">The c.</param>
        /// <returns></returns>
        public static IList<ReportGroupDto> FromModels(this IEnumerable<ReportGroupModel> c)
        {
            return c == null ? null : c.Select(source => FromModel((source))).ToList();
        }

        /// <summary>
        /// to
        /// To the data transfer objects.
        /// </summary>
        /// <param name="c">The c.</param>
        /// <returns></returns>
        public static IList<FixedAssetDto> FromModels(this IEnumerable<FixedAssetModel> c)
        {
            return c == null ? null : c.Select(source => FromModel((source))).ToList();
        }

        /// <summary>
        /// to
        /// To the data transfer objects.
        /// </summary>
        /// <param name="c">The c.</param>
        /// <returns></returns>
        public static IList<FixedAssetCategoryDto> FromModels(this IEnumerable<FixedAssetCategoryModel> c)
        {
            return c == null ? null : c.Select(source => FromModel((source))).ToList();
        }
        #endregion

        #region FromModel.

        /// <summary>
        /// To the data transfer object.
        /// </summary>
        /// <param name="c">The c.</param>
        /// <returns></returns>
        public static DepartmentDto FromModel(this DepartmentModel c)
        {
            if (c == null) return null;

            return new DepartmentDto
            {
                DepartmentId = c.DepartmentId,
                UnitId = c.UnitId,
                Code = c.Code,
                Name = c.Name,
                Address = c.Address,
                Description = c.Description,
                IsActive = c.IsActive,
                Fax = c.Fax,
                PhoneNumber = c.PhoneNumber,
                ParentId = c.ParentId,
            };
        }

        /// <summary>
        /// To the data transfer object.
        /// </summary>
        /// <param name="c">The c.</param>
        /// <returns></returns>
        public static UnitDto FromModel(this UnitModel c)
        {
            if (c == null) return null;
            return new UnitDto
            {

                UnitId = c.UnitId,
                ParentId = c.ParentId,
                Code = c.Code,
                Name = c.Name,
                Grade = c.Grade,
                IsActive = c.IsActive,
                HasParent = c.HasParent,
                PhoneNumber = c.PhoneNumber,
                Address = c.Address,
                ByManagement = c.ByManagement,
            };
        }

        /// <summary>
        /// To the data transfer object.
        /// </summary>
        /// <param name="c">The c.</param>
        /// <returns></returns>
        public static CustomerDto FromModel(this CustomerModel c)
        {
            return new CustomerDto
            {
                CustomerId = c.CustomerId,
                UnitId = c.UnitId,
                Code = c.Code,
                Name = c.Name,
                Address = c.Address,
                PhoneNumber = c.PhoneNumber,
                Fax = c.Fax,
                CompanyName = c.CompanyName,
                ContactName = c.ContactName,
                Description = c.Description,
                IsActive = c.IsActive,
            };
        }

        /// <summary>
        /// To the data transfer object.
        /// </summary>
        /// <param name="c">The c.</param>
        /// <returns></returns>
        public static CustomerModel FromModel(this CustomerDto c)
        {
            return new CustomerModel
            {
                CustomerId = c.CustomerId,
                UnitId = c.UnitId,
                Code = c.Code,
                Name = c.Name,
                Address = c.Address,
                PhoneNumber = c.PhoneNumber,
                Fax = c.Fax,
                CompanyName = c.CompanyName,
                ContactName = c.ContactName,
                Description = c.Description,
                IsActive = c.IsActive,                
            };
        }

        /// <summary>
        /// To the data transfer object.
        /// </summary>
        /// <param name="c">The c.</param>
        /// <returns></returns>
        public static VendorDto FromModel(this VendorModel c)
        {
            return new VendorDto
            {
                VendorId = c.VendorId,
                Code = c.Code,
                Name = c.Name,
                Address = c.Address,
                ContactName = c.ContactName,
                PhoneNumber = c.PhoneNumber,
                Description = c.Description,
                Fax = c.Fax,
                IsActive = c.IsActive,
                UnitId = c.UnitId,
            };
        }

        /// <summary>
        /// To the data transfer object.
        /// </summary>
        /// <param name="c">The c.</param>
        /// <returns></returns>
        public static VoucherTypeDto FromModel(this VoucherTypeModel c)
        {
            return new VoucherTypeDto
            {
                VoucherTypeId = c.VoucherTypeId,
                VoucherTypeName = c.VoucherTypeName,
                IsActive = c.IsActive
            };
        }

        /// <summary>
        /// To the data transfer object.
        /// </summary>
        /// <param name="c">The c.</param>
        /// <returns></returns>
        public static RefTypeDto FromModel(this RefTypeModel c)
        {
            return new RefTypeDto
            {
                RefTypeId = c.RefTypeId,
                MasterTable = c.MasterTable,
                Name = c.Name,
                DetailTable = c.DetailTable,
                Description = c.Description,
                IsActive = c.IsActive,
            };
        }

        /// <summary>
        /// To the data transfer object.
        /// </summary>
        /// <param name="c">The c.</param>
        /// <returns></returns>
        public static AutoBusinessDto FromModel(this AutoBusinessModel c)
        {
            return new AutoBusinessDto
            {
                AutoBusinessId = c.AutoBusinessId,
                AutoBusinessCode = c.AutoBusinessCode,
                AutoBusinessName = c.AutoBusinessName,
                RefTypeId = c.RefTypeId,
                VoucherTypeId = c.VoucherTypeId,
                DebitAccountNumber = c.DebitAccountNumber,
                CreditAccountNumber = c.CreditAccountNumber,
                //  BudgetItemCode = model.BudgetItemCode,
                //  BudgetSourceCode = model.BudgetSourceCode,
                Description = c.Description,
                IsActive = c.IsActive,
                UnitId = c.UnitId
            };
        }

        /// <summary>
        /// To the data transfer object.
        /// </summary>
        /// <param name="dbOption">The database option.</param>
        /// <returns></returns>
        public static DbOptionDto FromModel(this DbOptionModel dbOption)
        {
            if (dbOption == null) return null;

            return new DbOptionDto
            {
                OptionId = dbOption.OptionId,
                UnitId = dbOption.UnitId,
                Code = dbOption.Code,
                Value = dbOption.Value,
                ValueType = dbOption.ValueType,
                Description = dbOption.Description,
                IsSystem = dbOption.IsSystem
            };
        }

        /// <summary>
        /// To the data transfer object.
        /// </summary>
        /// <param name="c">The c.</param>
        /// <returns></returns>
        public static StockDto FromModel(this StockModel c)
        {
            if (c == null) return null;

            return new StockDto
            {
                StockId = c.StockId,
                StockCode = c.StockCode,
                StockName = c.StockName,
                Description = c.Description,
                IsActive = c.IsActive,
                UnitId = c.UnitId
            };
        }

        /// <summary>
        /// To the data transfer object.
        /// </summary>
        /// <param name="c">The c.</param>
        /// <returns></returns>
        public static InventoryItemDto FromModel(this InventoryItemModel c)
        {
            if (c == null) return null;

            return new InventoryItemDto
            {
                InventoryItemId = c.InventoryItemId,
                InventoryItemName = c.InventoryItemName,
                InventoryItemCode = c.InventoryItemCode,
                AccountCode = c.AccountCode,
                //  CurrencyCode = entity.CurrencyCode,
                IsActive = c.IsActive,
                //  CostMethod = entity.CostMethod,
                Unit = c.Unit,
                UnitId = c.UnitId
            };
        }

        /// <summary>
        /// Froms the data transfer object.
        /// </summary>
        /// <param name="c">The c.</param>
        /// <returns></returns>
        internal static AccountDto FromModel(this AccountModel c)
        {
            if (c == null) return null;

            return new AccountDto
            {
                AccountId = c.AccountId,
                UnitId = c.UnitId,
                AccountCode = c.AccountCode,
                AccountName = c.AccountName,
                ParentId = c.ParentId,
                Grade = c.Grade,
                IsDetail = c.IsDetail,
                Description = c.Description,
                IsCustomer = c.IsCustomer,
                IsVendor = c.IsVendor,
                IsTax = c.IsTax,
                IsInventoryItem = c.IsInventoryItem,
                IsFixedAsset = c.IsFixedAsset,
                IsActive = c.IsActive,
                IsSystem = c.IsSystem,
            };
        }

        /// <summary>
        /// To the data transfer object.
        /// </summary>
        /// <param name="c">The c.</param>
        /// <returns></returns>
        public static ReportListDto FromModel(this ReportListModel c)
        {
            if (c == null) return null;

            return new ReportListDto
            {
                Description = c.Description,
                File = c.File,
                FunctionReportName = c.FunctionReportName,
                Grade = c.Grade,
                InputTypeName = c.InputTypeName,
                IsActive = c.IsActive,
                IsTypical = c.IsTypical,
                Name = c.Name,
                ProcedureReportName = c.ProcedureReportName,
                ReportGroupId = c.ReportGroupId,
                ReportListId = c.ReportListId,
                SortOrder = c.SortOrder,
                TableName = c.TableName,
                Code = c.Code,
                ReportController = c.ReportController,
                ParentId = c.ParentId
            };
        }

        /// <summary>
        /// To the data transfer object.
        /// </summary>
        /// <param name="c">The c.</param>
        /// <returns></returns>
        public static ReportGroupDto FromModel(this ReportGroupModel c)
        {
            if (c == null) return null;

            return new ReportGroupDto
            {
                ReportGroupId = c.ReportGroupID,
                Name = c.ReportGroupName,
                Description = c.Description,
                IsVoucher = c.IsVoucher,
                IsActive = c.IsActive,
                IsTypical = c.IsTypical
            };
        }

        /// <summary>
        /// To the data transfer object.
        /// </summary>
        /// <param name="c">The c.</param>
        /// <returns></returns>
        public static FixedAssetDto FromModel(this FixedAssetModel c)
        {
            if (c == null) return null;

            return new FixedAssetDto
            {
                FixedAssetId = c.FixedAssetId,
                FixedAssetCode = c.FixedAssetCode,
                FixedAssetName = c.FixedAssetName,
                FixedAssetForeignName = c.FixedAssetForeignName,
                FixedAssetCategoryId = c.FixedAssetCategoryId,
                State = c.State,
                Description = c.Description,
                ProductionYear = c.ProductionYear,
                MadeIn = c.MadeIn,
                PurchasedDate = c.PurchasedDate,
                UsedDate = c.UsedDate,
                DepreciationDate = c.DepreciationDate,
                IncrementDate = c.IncrementDate,
                DisposedDate = c.DisposedDate,
                Unit = c.Unit,
                SerialNumber = c.SerialNumber,
                Accessories = c.Accessories,
                Quantity = c.Quantity,
                UnitPrice = c.UnitPrice,
                OrgPrice = c.OrgPrice,
                AccumDepreciationAmount = c.AccumDepreciationAmount,
                RemainingAmount = c.RemainingAmount,
                AnnualDepreciationAmount = c.AnnualDepreciationAmount,
                LifeTime = c.LifeTime,
                DepreciationRate = c.DepreciationRate,
                OrgPriceAccountCode = c.OrgPriceAccountCode,
                DepreciationAccountCode = c.DepreciationAccountCode,
                CapitalAccountCode = c.CapitalAccountCode,
                DepartmentId = c.DepartmentId,
                EmployeeId = c.EmployeeId,
                IsActive = c.IsActive,
                CapitalMoneyAccountCode = c.CapitalMoneyAccountCode,
                ExpenseAccountCode = c.ExpenseAccountCode,
                UnitId = c.UnitId
            };
        }

        /// <summary>
        /// To the data transfer object.
        /// </summary>
        /// <param name="c">The c.</param>
        /// <returns></returns>
        public static FixedAssetCategoryDto FromModel(this FixedAssetCategoryModel c)
        {
            if (c == null) return null;

            return new FixedAssetCategoryDto
            {
                FixedAssetCategoryId = c.FixedAssetCategoryId,
                ParentId = c.ParentId,
                FixedAssetCategoryCode = c.FixedAssetCategoryCode,
                FixedAssetCategoryName = c.FixedAssetCategoryName,
                DepreciationRate = c.DepreciationRate,
                LifeTime = c.LifeTime,
                Grade = c.Grade,
                IsParent = c.IsParent,
                OrgPriceAccountCode = c.OrgPriceAccountCode,
                DepreciationAccountCode = c.DepreciationAccountCode,
                CapitalAccountCode = c.CapitalAccountCode,
                IsActive = c.IsActive
            };
        }
        #endregion

        #region ToModel
        /// <summary>
        /// Froms the data transfer object.
        /// </summary>
        /// <param name="c">The c.</param>
        /// <returns></returns>
        public static DepartmentModel ToModels(this DepartmentDto c)
        {
            if (c == null) return null;

            return new DepartmentModel
            {
                DepartmentId = (int)c.DepartmentId,
                UnitId = c.UnitId,
                Code = c.Code,
                Name = c.Name,
                Address = c.Address,
                Description = c.Description,
                IsActive = c.IsActive,
                Fax = c.Fax,
                PhoneNumber = c.PhoneNumber,
                ParentId = c.ParentId,
            };
        }

        /// <summary>
        /// To the data transfer object.
        /// </summary>
        /// <param name="c">The c.</param>
        /// <returns></returns>
        public static UnitModel ToModels(this UnitDto c)
        {
            if (c == null) return null;
            return new UnitModel
            {
                UnitId = c.UnitId,
                ParentId = c.ParentId,
                Code = c.Code,
                Name = c.Name,
                Grade = c.Grade,
                IsActive = c.IsActive,
                HasParent = c.HasParent,
                PhoneNumber = c.PhoneNumber,
                Address = c.Address,
                ByManagement = c.ByManagement,
            };
        }

        /// <summary>
        /// To the data transfer object.
        /// </summary>
        /// <param name="c">The c.</param>
        /// <returns></returns>
        public static CustomerModel ToModel(this CustomerDto c)
        {
            return new CustomerModel
            {
                CustomerId = c.CustomerId,
                UnitId = c.UnitId,
                Code = c.Code,
                Name = c.Name,
                Address = c.Address,
                PhoneNumber = c.PhoneNumber,
                Fax = c.Fax,
                CompanyName = c.CompanyName,
                ContactName = c.ContactName,
                Description = c.Description,
                IsActive = c.IsActive,
            };
        }

        /// <summary>
        /// To the data transfer object.
        /// </summary>
        /// <param name="c">The c.</param>
        /// <returns></returns>
        public static CustomerDto ToModels(this CustomerModel c)
        {
            return new CustomerDto
            {
                CustomerId = c.CustomerId,
                UnitId = c.UnitId,
                Code = c.Code,
                Name = c.Name,
                Address = c.Address,
                PhoneNumber = c.PhoneNumber,
                Fax = c.Fax,
                CompanyName = c.CompanyName,
                ContactName = c.ContactName,
                Description = c.Description,
                IsActive = c.IsActive,
            };
        }

        /// <summary>
        /// To the data transfer object.
        /// </summary>
        /// <param name="c">The c.</param>
        /// <returns></returns>
        public static VendorModel ToModels(this VendorDto c)
        {
            return new VendorModel
            {
                VendorId = c.VendorId,
                Code = c.Code,
                Name = c.Name,
                Address = c.Address,
                ContactName = c.ContactName,
                PhoneNumber = c.PhoneNumber,
                Description = c.Description,
                Fax = c.Fax,
                IsActive = c.IsActive,
                UnitId = c.UnitId,
            };
        }


        /// <summary>
        /// To the data transfer object.
        /// </summary>
        /// <param name="c">The c.</param>
        /// <returns></returns>
        public static VoucherTypeModel ToModels(this VoucherTypeDto c)
        {
            return new VoucherTypeModel
            {
                VoucherTypeId = c.VoucherTypeId,
                VoucherTypeName = c.VoucherTypeName,
                IsActive = c.IsActive
            };
        }

        /// <summary>
        /// To the data transfer object.
        /// </summary>
        /// <param name="c">The c.</param>
        /// <returns></returns>
        public static RefTypeModel ToModels(this RefTypeDto c)
        {
            return new RefTypeModel
            {
                RefTypeId = c.RefTypeId,
                MasterTable = c.MasterTable,
                Name = c.Name,
                DetailTable = c.DetailTable,
                Description = c.Description,
                IsActive = c.IsActive,
            };
        }


        /// <summary>
        /// Froms the data transfer object.
        /// </summary>
        /// <param name="c">The c.</param>
        /// <returns></returns>
        public static AutoBusinessModel ToModels(this AutoBusinessDto c)
        {
            if (c == null) return null;

            return new AutoBusinessModel
            {
                AutoBusinessId = c.AutoBusinessId,
                AutoBusinessCode = c.AutoBusinessCode,
                AutoBusinessName = c.AutoBusinessName,
                RefTypeId = c.RefTypeId,
                VoucherTypeId = c.VoucherTypeId,
                DebitAccountNumber = c.DebitAccountNumber,
                CreditAccountNumber = c.CreditAccountNumber,
                // BudgetSourceCode = entity.BudgetSourceCode,
                // BudgetItemCode = entity.BudgetItemCode,
                Description = c.Description,
                IsActive = c.IsActive,
                UnitId = c.UnitId
            };
        }

        /// <summary>
        /// Froms the data transfer object.
        /// </summary>
        /// <param name="c">The c.</param>
        /// <returns></returns>
        public static DbOptionModel ToModels(this DbOptionDto c)
        {
            if (c == null) return null;

            return new DbOptionModel
            {
                OptionId = c.OptionId,
                UnitId = c.UnitId,
                Code = c.Code,
                Value = c.Value,
                ValueType = c.ValueType,
                Description = c.Description,
                IsSystem = c.IsSystem
            };
        }

        /// <summary>
        /// Froms the data transfer object.
        /// </summary>
        /// <param name="c">The c.</param>
        /// <returns></returns>
        public static StockModel ToModels(this StockDto c)
        {
            if (c == null) return null;

            return new StockModel
            {
                StockId = c.StockId,
                StockCode = c.StockCode,
                StockName = c.StockName,
                Description = c.Description,
                IsActive = c.IsActive,
                UnitId = c.UnitId
            };
        }

        /// <summary>
        /// Froms the data transfer object.
        /// </summary>
        /// <param name="c">The c.</param>
        /// <returns></returns>
        public static InventoryItemModel ToModels(this InventoryItemDto c)
        {
            if (c == null) return null;

            return new InventoryItemModel
            {
                InventoryItemId = c.InventoryItemId,
                InventoryItemName = c.InventoryItemName,
                InventoryItemCode = c.InventoryItemCode,
                AccountCode = c.AccountCode,
                //  CurrencyCode = entity.CurrencyCode,
                IsActive = c.IsActive,
                //  CostMethod = entity.CostMethod,
                Unit = c.Unit,
                UnitId = c.UnitId
            };
        }

        /// <summary>
        /// Froms the data transfer object.
        /// </summary>
        /// <param name="dto">The dto.</param>
        /// <returns></returns>
        internal static AccountModel ToModels(this AccountDto dto)
        {
            if (dto == null) return null;

            return new AccountModel
            {
                AccountId = dto.AccountId,
                UnitId = dto.UnitId,
                AccountCode = dto.AccountCode,
                AccountName = dto.AccountName,
                ParentId = dto.ParentId,
                Grade = dto.Grade,
                IsDetail = dto.IsDetail,
                Description = dto.Description,
                IsCustomer = dto.IsCustomer,
                IsVendor = dto.IsVendor,
                IsTax = dto.IsTax,
                IsInventoryItem = dto.IsInventoryItem,
                IsFixedAsset = dto.IsFixedAsset,
                IsActive = dto.IsActive,
                IsSystem = dto.IsSystem,
            };
        }

        /// <summary>
        /// Froms the data transfer object.
        /// </summary>
        /// <param name="dto">The dto.</param>
        /// <returns></returns>
        internal static ReportListModel ToModels(this ReportListDto dto)
        {
            if (dto == null) return null;

            return new ReportListModel
            {
                Description = dto.Description,
                File = dto.File,
                FunctionReportName = dto.FunctionReportName,
                Grade = dto.Grade,
                InputTypeName = dto.InputTypeName,
                IsActive = dto.IsActive,
                IsTypical = dto.IsTypical,
                Name = dto.Name,
                ProcedureReportName = dto.ProcedureReportName,
                ReportGroupId = dto.ReportGroupId,
                ReportListId = dto.ReportListId,
                SortOrder = dto.SortOrder,
                TableName = dto.TableName,
                Code = dto.Code,
                ReportController = dto.ReportController,
                ParentId = dto.ParentId
            };
        }

        /// <summary>
        /// Froms the data transfer object.
        /// </summary>
        /// <param name="dto">The dto.</param>
        /// <returns></returns>
        internal static ReportGroupModel ToModels(this ReportGroupDto dto)
        {
            if (dto == null) return null;

            return new ReportGroupModel
            {
                ReportGroupID = dto.ReportGroupId,
                ReportGroupName = dto.Name,
                Description = dto.Description,
                IsVoucher = dto.IsVoucher,
                IsActive = dto.IsActive,
                IsTypical = dto.IsTypical
            };
        }

        /// <summary>
        /// Froms the data transfer object.
        /// </summary>
        /// <param name="dto">The dto.</param>
        /// <returns></returns>
        internal static FixedAssetModel ToModels(this FixedAssetDto dto)
        {
            if (dto == null) return null;

            return new FixedAssetModel
            {
                FixedAssetId = dto.FixedAssetId,
                FixedAssetCode = dto.FixedAssetCode,
                FixedAssetName = dto.FixedAssetName,
                FixedAssetForeignName = dto.FixedAssetForeignName,
                FixedAssetCategoryId = dto.FixedAssetCategoryId,
                State = dto.State,
                Description = dto.Description,
                ProductionYear = dto.ProductionYear,
                MadeIn = dto.MadeIn,
                PurchasedDate = dto.PurchasedDate,
                UsedDate = dto.UsedDate,
                DepreciationDate = dto.DepreciationDate,
                IncrementDate = dto.IncrementDate,
                DisposedDate = dto.DisposedDate,
                Unit = dto.Unit,
                SerialNumber = dto.SerialNumber,
                Accessories = dto.Accessories,
                Quantity = dto.Quantity,
                UnitPrice = dto.UnitPrice,
                OrgPrice = dto.OrgPrice,
                AccumDepreciationAmount = dto.AccumDepreciationAmount,
                RemainingAmount = dto.RemainingAmount,
                AnnualDepreciationAmount = dto.AnnualDepreciationAmount,
                LifeTime = dto.LifeTime,
                DepreciationRate = dto.DepreciationRate,
                OrgPriceAccountCode = dto.OrgPriceAccountCode,
                DepreciationAccountCode = dto.DepreciationAccountCode,
                CapitalAccountCode = dto.CapitalAccountCode,
                DepartmentId = dto.DepartmentId,
                EmployeeId = dto.EmployeeId,
                IsActive = dto.IsActive,
                CapitalMoneyAccountCode = dto.CapitalMoneyAccountCode,
                ExpenseAccountCode = dto.ExpenseAccountCode,
                UnitId = dto.UnitId
            };
        }

        /// <summary>
        /// Froms the data transfer object.
        /// </summary>
        /// <param name="dto">The dto.</param>
        /// <returns></returns>
        internal static FixedAssetCategoryModel ToModels(this FixedAssetCategoryDto dto)
        {
            if (dto == null) return null;

            return new FixedAssetCategoryModel
            {
                FixedAssetCategoryId = (int)dto.FixedAssetCategoryId,
                ParentId = dto.ParentId,
                FixedAssetCategoryCode = dto.FixedAssetCategoryCode,
                FixedAssetCategoryName = dto.FixedAssetCategoryName,
                DepreciationRate = dto.DepreciationRate,
                LifeTime = dto.LifeTime,
                Grade = dto.Grade,
                IsParent = dto.IsParent,
                OrgPriceAccountCode = dto.OrgPriceAccountCode,
                DepreciationAccountCode = dto.DepreciationAccountCode,
                CapitalAccountCode = dto.CapitalAccountCode,
                IsActive = dto.IsActive,
                UnitId = dto.UnitId
            };
        }

        #endregion

        #region ToModels
        /// <summary>
        /// Froms the data transfer objects.
        /// </summary>
        /// <param name="c">The c.</param>
        /// <returns></returns>
        public static IList<DepartmentModel> ToModels(this IEnumerable<DepartmentDto> c)
        {
            return c == null ? null : c.Select(source => ToModels((source))).ToList();
        }

        /// <summary>
        /// Froms the data transfer objects.
        /// </summary>
        /// <param name="c">The c.</param>
        /// <returns></returns>
        public static IList<UnitModel> ToModels(this IEnumerable<UnitDto> c)
        {
            return c == null ? null : c.Select(source => ToModels((source))).ToList();
        }

        /// <summary>
        /// Froms the data transfer objects.
        /// </summary>
        /// <param name="c">The c.</param>
        /// <returns></returns>
        public static IList<CustomerModel> ToModels(this IEnumerable<CustomerDto> c)
        {
            return c.Select(item => item.ToModel()).ToList();
        }

        /// <summary>
        /// Froms the data transfer objects.
        /// </summary>
        /// <param name="c">The c.</param>
        /// <returns></returns>
        public static IList<CustomerDto> ToModels(this IEnumerable<CustomerModel> c)
        {
            return c == null ? null : c.Select(ToModels).ToList();
        }

        /// <summary>
        /// Froms the data transfer objects.
        /// </summary>
        /// <param name="c">The c.</param>
        /// <returns></returns>
        public static IList<VendorModel> ToModels(this IEnumerable<VendorDto> c)
        {
            return c == null ? null : c.Select(source => ToModels((source))).ToList();
        }

        /// <summary>
        /// Froms the data transfer objects.
        /// </summary>
        /// <param name="c">The c.</param>
        /// <returns></returns>
        public static IList<VoucherTypeModel> ToModels(this IEnumerable<VoucherTypeDto> c)
        {
            return c == null ? null : c.Select(source => ToModels((source))).ToList();
        }

        /// <summary>
        /// Froms the data transfer objects.
        /// </summary>
        /// <param name="c">The c.</param>
        /// <returns></returns>
        public static IList<RefTypeModel> ToModels(this IEnumerable<RefTypeDto> c)
        {
            return c == null ? null : c.Select(source => ToModels((source))).ToList();
        }

        /// <summary>
        /// Froms the data transfer objects.
        /// </summary>
        /// <param name="c">The c.</param>
        /// <returns></returns>
        public static IList<AutoBusinessModel> ToModels(this IEnumerable<AutoBusinessDto> c)
        {
            return c == null ? null : c.Select(source => ToModels((source))).ToList();
        }

        /// <summary>
        /// Froms the data transfer objects.
        /// </summary>
        /// <param name="c">The c.</param>
        /// <returns></returns>
        public static IList<DbOptionModel> ToModels(this IEnumerable<DbOptionDto> c)
        {
            return c == null ? null : c.Select(source => ToModels((source))).ToList();
        }

        /// <summary>
        /// Froms the data transfer objects.
        /// </summary>
        /// <param name="c">The c.</param>
        /// <returns></returns>
        public static IList<StockModel> ToModels(this IEnumerable<StockDto> c)
        {
            return c == null ? null : c.Select(source => ToModels((source))).ToList();
        }

        /// <summary>
        /// Froms the data transfer objects.
        /// </summary>
        /// <param name="c">The c.</param>
        /// <returns></returns>
        public static IList<InventoryItemModel> ToModels(this IEnumerable<InventoryItemDto> c)
        {
            return c == null ? null : c.Select(source => ToModels((source))).ToList();
        }

        /// <summary>
        /// Froms the data transfer objects.
        /// </summary>
        /// <param name="c">The c.</param>
        /// <returns></returns>
        public static IList<AccountModel> ToModels(this IEnumerable<AccountDto> c)
        {
            return c == null ? null : c.Select(source => ToModels((source))).ToList();
        }

        /// <summary>
        /// Froms the data transfer objects.
        /// </summary>
        /// <param name="c">The c.</param>
        /// <returns></returns>
        public static List<ReportListModel> ToModels(this IEnumerable<ReportListDto> c)
        {
            return c == null ? null : c.Select(source => ToModels((source))).ToList();
        }        

        /// <summary>
        /// Froms the data transfer object.
        /// </summary>
        /// <param name="c">The c.</param>
        /// <returns></returns>
        public static List<ReportGroupModel> ToModels(this IEnumerable<ReportGroupDto> c)
        {
            return c == null ? null : c.Select(source => ToModels((source))).ToList();
        }        

        /// <summary>
        /// Froms the data transfer objects.
        /// </summary>
        /// <param name="c">The c.</param>
        /// <returns></returns>
        public static IList<FixedAssetModel> ToModels(this IEnumerable<FixedAssetDto> c)
        {
            return c == null ? null : c.Select(source => ToModels((source))).ToList();
        }

        /// <summary>
        /// Froms the data transfer objects.
        /// </summary>
        /// <param name="c">The c.</param>
        /// <returns></returns>
        public static IList<FixedAssetCategoryModel> ToModels(this IEnumerable<FixedAssetCategoryDto> c)
        {
            return c == null ? null : c.Select(source => ToModels((source))).ToList();
        }
        #endregion

    }
}